package com.yanqu.road.server.logic.activity.condition.gashapon;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseActivityCondition;
import com.yanqu.road.server.manger.activity.ActivityMgr;

import java.math.BigInteger;

/**
 * @Author : Cxp
 * @Time : 2024-10-22
 * @Description : 幸运扭蛋-元宝返利
 */

public class GashaponIngotRebateCondition extends BaseActivityCondition {
    public GashaponIngotRebateCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        long arg = (long) object;

        BigInteger newValue = BigInteger.valueOf(arg);

        if (newValue.compareTo(getValue()) > 0) {
            setValue(newValue);
        }
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.GashaponIngotRebate.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.GashaponIngotRebate.getValue(), handle);
    }

    @Override
    public boolean isCompleted(GamePlayer player) {
        return getValue().compareTo(activityConditionInfo.getParamList().get(0)) >= 0;
    }

    @Override
    public boolean canChange(ActivityInfo activityInfo) {
        return ActivityMgr.activityInShowTime(activityInfo);
    }
}
